*Analysis Do-File for creating Figures 4
	*Figures are separated in to 4a,b,c,d
*Runs event study regressions and produces graphs of effects over time

***File set-up
macro drop _all
mat drop _all
eststo clear
estimates clear
global path "[ENTER PATH HERE]"
global figs "$path\REStat Replication V2\Figures"
global log "$path\REStat Replication V2\Log Files"
set scheme lean2

clear
set more off

cap log close
log using "$log\figure_4.txt", replace text
use "$path\REStat Replication V2\Data\master_data_analysis_subset"

*Set folder for main figures
cd "$figs"



***Loops through arrest types, producing the estimates that go into Figure 4
foreach var of varlist disorder_cond_tot poss_cannabis_tot liquor_tot sale_cannabis_tot {
	
	*Since all arrests are part 1 offenses, ensure that crime data is non-missing
		di "------Reg `var' arrests------"
		reghdfe ln_`var' ln_pop_s ///
			qtr_neg4_binned-qtr_neg2  qtr_0-qtr_6_binned ///
			if !inlist(., ln_actual_index_violent, ln_actual_index_property) ///
			, cl(group_ori) absorb(group_ori month_year)
			
		*Call plot code
		qui do "$path\REStat Replication\Code\coef_plot_quart"
			
		*Plot the normalized coefficents and SEs
		*Normalized to the quarter right before officer-involved fatality
		qui coefplot mat(coef_1000[,1]), vertical yline(0) se(2)  /// 
			yscale(range(-0.5 0.1))  ylabel(-0.5(0.1)0.1, glcolor(gs12)) ///
			msize(large) msymbol(O) mfcolor(black%100) mcolor(white%0) ///
			xtitle(Quarter Relative to Event) ytitle(Log Points) ///
			xline(3.5, lpattern(dash) lcolor(red) axis(1))
		if "`var'" == "disorder_cond_tot" {
			graph export "figure_4a.pdf", replace
		}
		else if "`var'" == "poss_cannabis_tot" {
			graph export "figure_4b.pdf", replace
		}
		else if "`var'" == "liquor_tot" {
			graph export "figure_4c.pdf", replace			
		}
		else if "`var'" == "sale_cannabis_tot" {
			graph export "figure_4d.pdf", replace			
		}
}


cap log close

